﻿<template>
    <div class="table">
        <div class="divSearch" >
            <Row>
                <!-- <Col :lg="{span:5}" :md="{span:8}" :sm="{span:12}" :xs="{span:22}">
                    <label class="searchLabel">所属地区:</label>
                    <Cascader :data="AreaList" change-on-select @on-change='SearchCascaderChange'  class="searchInput"></Cascader>
                    <Select v-model="searchModel.AreaCode"  placeholder="请选择..."  @on-change="getStatsData()" class="searchInput">
                        <Option :value="userinfo.AreaCode">全市(州)</Option>
                        <Option :value="item.value" v-for="item in AreaList" :key="item.value">{{item.label}}</Option>
                    </Select>
                </Col> -->
            <!--搜索框-->
                <Col :lg="{span:5}" :md="{span:8}" :sm="{span:12}" :xs="{span:22}">
                    <label class="searchLabel">填报年度:</label>
                    <Select v-model="searchModel.FillInYear" @on-change="getStatsData()" placeholder="请选择..." :label-in-value="true" clearable class="searchInput">
                        <Option :value="item.DictText" v-for="item in CreateYearList" :key="item.DictValue">{{item.DictText}}</Option>
                    </Select>
                    <Button style="margin: 9px" type="primary" @click="DataExport()"  class="searchButton" >导出</Button>
                </Col>
            </Row>
        </div>
        <Row>
            <!-- 列表-->
            <div >
                <Row>
                    <Col>
                        <Table :context="self" ref="table" :stripe=true  :data="datas" no-data-text='暂无数据...' :border=true :columns="TableHeader" size="large" :height="clientHeight">
                        </Table>
                    </Col>
                </Row>
                <Row >
                    <Col span="24" class="dataTable">
                        <!-- <Page  class="page-style" :total="total" placement="top" show-total show-elevator></Page> -->
                        <Page style="float:right;margin: 5px 20px 5px 0;" class="page-style" :total="datas.length" placement="top" @on-change="getPageNumber" :page-size="searchModel.PageSize" :page-size-opts='pageSizeOpts' show-sizer @on-page-size-change="getPageSize" show-total show-elevator></Page>
                    </Col>
                </Row>
            </div>
         </Row>
    </div>
</template>
<script>
export default {
    data() {
        return {
            self: this,
            CreateYearList: this.GetGroupDict("ReportYear"), //年度
            CurrentYear: this.GetCurrentYear(),//当前年度
            AreaList: [],
            pageSizeOpts: [20, 40, 50],//默认分页最大设置
            TotalData:[],
            CurrentAreaName:'',
            userinfo: this.GetlocaStorage("CSuserinfo"),//获取当前用户信息
            datas:[],//列表数据
            SelectName:'',
            //列表头部
            TableHeader: [
                 {
                    title: '公司名称',
                    key: 'CompanyName'
                },
                {
                    title: '固定资产',
                    key: 'GDZC'
                },
                {
                    title: '缫丝能力',
                    key: 'CSNL'
                },
                {
                    title: '白厂丝产量',
                    key: 'BCSCL'
                },
                {
                    title: '丝绸产量',
                    key: 'SCCL'
                },
                {
                    title: '年加工蚕丝被',
                    key: 'NJGCSB'
                },
                {
                    title: '其它',
                    key: 'Other'
                },
                {
                    title: '备注',
                    key: 'Remark'
                }
            ],
            //查询模型：根据需求删除不不要查询条件
            //蔬菜生产情况表代码
            searchModel: {
                Id: '',
                ReportCode: 'CompanyInfo',
                FillInYear: '',
                TimesType: '',
                AreaCode: this.GetlocaStorage("CSuserinfo").AreaCode,
                PageNumber: 1,
                PageSize: 20,
                Status: '4',
                Opinion: ''
            },
            clientHeight: window.innerHeight - 280,//表格默认高度
            listShow:false,//列表显示控制器
            pieShow:false,//饼图显示控制器
            mapShow:false,//地图显示控制器
            total:100
        }
    },
    //高度计算
     mounted() {
        //table高度计算方法
        const that = this;
        window.onresize = () => {
            return (() => {
                that.clientHeight = window.innerHeight - 220;
            })()
        };
    },
    //方法
    methods: {  
        //获取当前页码
        getPageNumber(pageIndex) {
            this.searchModel.PageNumber = pageIndex;
            this.getStatsData();
        },
        //获取当前分页大小
        getPageSize(pageSize) {
            this.searchModel.PageSize = pageSize;
            this.getStatsData();
        },
        //获取地区统计数据
        getStatsData(){
            var self = this;
            if (self.searchModel.FillInYear != null && self.searchModel.FillInYear != '') {
                self.searchModel.FillInYear = self.searchModel.FillInYear;//获取当前系统年份
            } 
            else {
                self.searchModel.FillInYear = self.CurrentYear + '年'; //获取填报年度-----数据字典值
            }
            self.$http.post('MulSilkCompany/PostStatsList', self.searchModel).then(function (res) {
                if (res.data.status === 1) {
                    if (res.data.model!=null) {
                        self.datas=res.data.model;//列表赋值
                    }
                }
                else {
                    self.$Modal.error({
                    title: '提示信息',
                    content: res.data.message
                    });
                }
            });
        },
        GetData(obj){
            this.getStatsData(obj);
        },
        DataExport(){
            //导出
           var self = this;
            var user = self.GetlocaStorage("CSuserinfo");
            if (self.searchModel.FillInYear != null && self.searchModel.FillInYear != '') {
                self.searchModel.FillInYear = self.searchModel.FillInYear;//获取当前系统年份
            } 
            else {
                self.searchModel.FillInYear = self.CurrentYear + '年'; //获取填报年度-----数据字典值
            }
            window.open(this.$http.defaults.baseURL + "MulSilkCompany/GetStatsExcelData?FillInYear=" + self.searchModel.FillInYear+"&&AreaCode=" + user.AreaCode+"&&Status=" + self.searchModel.Status);
        },
    },
    //创建Vue页面方法
    created: function () { 
        this.getStatsData();
        // this.GetData({label:'现有桑园',value:'1'});
        // this.getStatsData({label:'现有桑园',value:'1'});   //获取地区统计数据      
    },
    watch: {
        //需要监听的在此处新增监听对象
    }
}
</script>
<style scoped src="../../styles/stats.css"></style>